package edu.towson.greenteam.command;

import edu.towson.greenteam.InformationAggregator;
import edu.towson.greenteam.Iterator;
import edu.towson.greenteam.menu.MenuItem;

public class CMDAddItemRating implements Command {
	
	InformationAggregator ia;
	int id;
	int rating;
	
	public CMDAddItemRating(InformationAggregator ia, int id, int rating) {
		this.ia = ia;
		this.id = id;
		this.rating = rating;
	}

	@Override
	public Object execute() {
		Iterator<MenuItem> i = ia.getMenu().getItr();
		MenuItem current;
		while (i.hasNext()) {
			current = i.next();
			if (current.getId() == id) {
				current.setRating(rating);
				return true;
			}
		}
		return false;
	}

}